package com.blb.community.controller;

import com.blb.community.Annotation.Log;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.blb.community.entity.ZyComment;
import com.blb.community.service.IZyCommentService;
import com.blb.community.utils.ResponseResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 评论表 前端控制器
 * </p>
 *
 * @author 帅帅
 * @since 2022-07-02
 */
@RestController
@Api(tags = "社区互动回复")
@RequestMapping("/zy-comment")
public class ZyCommentController {

    @Autowired
    private IZyCommentService commentService;

    @ApiOperation("社区互动回复")
    @GetMapping("/comments/{interactionId}")
    public ResponseResult<List<ZyComment>> getList(@PathVariable String interactionId){
        QueryWrapper<ZyComment> zyCommentQueryWrapper = new QueryWrapper<ZyComment>();
        zyCommentQueryWrapper.eq("interaction_id",interactionId);
        zyCommentQueryWrapper.eq("del_flag",0);
        List<ZyComment> list = commentService.list(zyCommentQueryWrapper);
        return ResponseResult.ok(list);
    }
    @Log(module = "社区互动回复删除", operationType = 3, requestMethod = "DELETE")
    @ApiOperation("社区互动回复删除")
    @DeleteMapping("/comment/{id}")
    public ResponseResult<String> delComment(@PathVariable Long id){
        commentService.delComment(id);
        return ResponseResult.ok("删除成功");
    }
}
